import org.junit.jupiter.api.*;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.*;
import org.openqa.selenium.Beta;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.Resource;
import java.util.stream.Stream;

public class JunitTest {
    public static Stream<Arguments> Generator() {
        return Stream.of(Arguments.arguments(1,"张三"),
                Arguments.arguments(2,"李四"),
                Arguments.arguments(3,"王五")
                );
    }

    @Test
    void Test01() {
        System.out.println("这是Junit里的test01");;
    }

    @Test
    void Test02() {
        System.out.println("这是Junit里的test02");;
    }

    @Disabled
    void Test03() {
        WebDriver webDriver = new ChromeDriver();
        webDriver.get("https://www.baidu.com/");
        webDriver.findElement(By.cssSelector("#s-top-left > a:nth-child(3)"));
    }

    /*@BeforeAll
    static void setUp() {
        System.out.println("这是BeforeAll里面的语句");
    }

    @AfterAll
    static void TearDown() {
        System.out.println("这是AfterAll里面的语句");
    }*/

    @BeforeEach
    void BeforeEachTest () {
        System.out.println("这是BeforeEach里面的语句");
    }

    @AfterEach
    void AfterEachTest () {
        System.out.println("这是AfterEach里面的语句");
    }

    @ParameterizedTest
    @ValueSource(ints = {1,2,3})
    void Test04(int num) {
        System.out.println(num);
    }

    @ParameterizedTest
    @ValueSource(strings = {"1","2","3"})
    void Test04(String number) {
        System.out.println(number);
    }

    @ParameterizedTest
    @CsvFileSource(resources = "test01.csv")
    void Test06(String name) {
        System.out.println(name);
    }

    @ParameterizedTest
    @MethodSource("Generator")
    void Test07(int num,String name) {
        System.out.println(num + name);
    }

}
